var mongoose = require('mongoose')
var Schema = mongoose.Schema

var adminSchema = new Schema({
    email: {
        type: String,
        required: true
    },
    adminName: {
        type: String,
        required: true
    },
    password: {
        type: String,
        required: true
    },
    create_time: {
        type: Date,
        default: Date.now()
    },
    role: {
        type: String,
        default: '管理员'
    },
    user_state: {
        type: Boolean,
        default: true
    },
    levels: {
        type: Number,
        default: 2
    },
    userDescription: {
        type: String,
        default: '--默认描述'
    },
    children: [{
            id: {
                type: Number,
                required: true
            },
            rightsName: {
                type: String,
                required: true
            },
            children: [{
                id: {
                    type: Number,
                    required: true
                },
                rightsName: {
                    type: String,
                    required: true
                }
            }]
        },
        {
            id: {
                type: Number,
                required: true
            },
            rightsName: {
                type: String,
                required: true
            },
            children: [{
                id: {
                    type: Number,
                    required: true
                },
                rightsName: {
                    type: String,
                    required: true
                }
            }]
        }
    ]
})

module.exports = mongoose.model('Admin', adminSchema)